<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>轮播图</title>

    <style>
        .box {
            height: 500px;
            width: 1000px;
            background-color: #9c74fa;
            border-radius: 15px;
            margin: 200px auto;
            position: relative;
            overflow: hidden;
        }

        .left {
            position: absolute;
            top: 50%;
            transform: translate(10px, -50%) scaleX(-1);
        }

        .right {
            position: absolute;
            top: 50%;
            right: 0;
            transform: translate(-10px, -50%);
        }

        .left,
        .right {
            display: none;
        }

        .left,
        .right,
        .point span:hover {
            cursor: pointer;
        }

        .box:hover .left,
        .box:hover .right {
            display: block;
        }

        .point {
            width: 100px;
            height: 13px;
            background-color: rgba(59, 58, 58, 0.15);
            border-radius: 10px;
            position: absolute;
            bottom: 0;
            left: 50%;
            transform: translate(-50%, -10px);
            display: flex;
            justify-content: space-around;
            align-items: center;
        }

        .point span {
            display: inline-block;
            background-color: #b9b5b5;
            width: 8px;
            height: 8px;
            border-radius: 50%;
        }

        .point .active {
            background-color: #fff;
        }

        li {

            list-style: none;
        }

        ul {
            margin: 0;
            padding: 0;
            display: flex;
        }

        ul li a img {
            height: 500px;
            width: 1000px;
        }
    </style>
</head>

<body>
    <div class="box">
        <ul>
            <li><a href=""><img src="../images/壁纸1.jpg" alt=""></a></li>
            <li><a href=""><img src="../images/壁纸2.jpg" alt=""></a></li>
            <li><a href=""><img src="../images/壁纸3.jpg" alt=""></a></li>
            <li><a href=""><img src="../images/壁纸4.jpg" alt=""></a></li>
            <li><a href=""><img src="../images/壁纸5.jpg" alt=""></a></li>
        </ul>
        <span class="left"><img src="../images/right.png" alt=""></span>
        <span class="right"><img src="../images/right.png" alt=""></span>
        <div class="point">
            <span class="active"></span>
            <span></span>
            <span></span>
            <span></span>
            <span></span>
        </div>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', function () {
            var box = document.querySelector('.box');
            var ul = document.querySelector('.box ul');
            var left = document.querySelector('.left');
            var right = document.querySelector('.right');
            var points = document.querySelectorAll('.point span');
            var images = document.querySelectorAll('.box ul li img');
            var currentIndex = 0;
            var totalImages = images.length;

            function updatePoints() {
                points.forEach(function (point, index) {
                    if (index === currentIndex) {
                        point.classList.add('active');
                    } else {
                        point.classList.remove('active');
                    }
                });
            }

            function moveToNextImage() {
                currentIndex = (currentIndex + 1) % totalImages;
                ul.style.transform = 'translateX(-' + (currentIndex * 100) + '%)';
                updatePoints();
            }

            function moveToPrevImage() {
                currentIndex = (currentIndex - 1 + totalImages) % totalImages;
                ul.style.transform = 'translateX(-' + (currentIndex * 100) + '%)';
                updatePoints();
            }

            left.addEventListener('click', moveToPrevImage);
            right.addEventListener('click', moveToNextImage);

            points.forEach(function (point, index) {
                point.addEventListener('click', function () {
                    currentIndex = index;
                    ul.style.transform = 'translateX(-' + (currentIndex * 100) + '%)';
                    updatePoints();
                });
            });

            setInterval(moveToNextImage, 3000);
        });
    </script>
</body>

</html>